<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>getElementById()</title>
</head>
<body>
<h2 id="myHeader">旧文本</h2>
<button onclick="displayResult()">改变</button>
<script>
    function displayResult() {
        document.getElementById("myHeader").innerHTML = "新文本!";
    }
</script>
</body>
</html>